package ppjava12v1.chess.desk;

import ppjava12v1.chess.enums.Side;

/**
 * Created by Reyst on 05.10.2014.
 */
public class Desk {

    /**
     * first index - it's row
     * second index - it's column
     */
    private Cell[][] chessDesc = new Cell[8][8];

    private boolean whiteKingMoved = false;
    private boolean blackKingMoved = false;

    private boolean whiteLRookMoved = false;
    private boolean whiteRRookMoved = false;

    private boolean blackLRookMoved = false;
    private boolean blackRRookMoved = false;

    private boolean checkToBlack = false;
    private boolean checkToWhite = false;

    private Side currentMove = Side.WHITE;

    public Desk() {
        chessDesc = new Cell[8][8];
        currentMove = Side.WHITE;
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
              chessDesc[i][j] = new Cell();
                  }
              }
    }

    public Cell[][] getChessDesc() {
        return chessDesc;
    }

    public Figure getFigureFromCell(int row, int col) {

        if (row < 1 || row > 8) return null;
        if (col < 1 || col > 8) return null;

        return chessDesc[row - 1][col - 1].getFigure();
    }

    public void putFigureTo(int row, int col, Figure figure) {

        if (row < 1 || row > 8) return;
        if (col < 1 || col > 8) return;

        chessDesc[row-1][col-1].setFigure(figure);
    }

    public void removeFigureFrom(int row, int col) {

        if (row < 1 || row > 8) return;
        if (col < 1 || col > 8) return;

        chessDesc[row - 1][col - 1].setFigure(null);
    }

    public void setChessDesc(Cell[][] chessDesc) {
        this.chessDesc = chessDesc;
    }

    public boolean isWhiteKingMoved() {
        return whiteKingMoved;
    }

    public void setWhiteKingMoved(boolean whiteKingMoved) {
        this.whiteKingMoved = whiteKingMoved;
    }

    public boolean isBlackKingMoved() {
        return blackKingMoved;
    }

    public void setBlackKingMoved(boolean blackKingMoved) {
        this.blackKingMoved = blackKingMoved;
    }

    public boolean isWhiteLRookMoved() {
        return whiteLRookMoved;
    }

    public void setWhiteLRookMoved(boolean whiteLRookMoved) {
        this.whiteLRookMoved = whiteLRookMoved;
    }

    public boolean isWhiteRRookMoved() {
        return whiteRRookMoved;
    }

    public void setWhiteRRookMoved(boolean whiteRRookMoved) {
        this.whiteRRookMoved = whiteRRookMoved;
    }

    public boolean isBlackLRookMoved() {
        return blackLRookMoved;
    }

    public void setBlackLRookMoved(boolean blackLRookMoved) {
        this.blackLRookMoved = blackLRookMoved;
    }

    public boolean isBlackRRookMoved() {
        return blackRRookMoved;
    }

    public void setBlackRRookMoved(boolean blackRRookMoved) {
        this.blackRRookMoved = blackRRookMoved;
    }

    public boolean isCheckToBlack() {
        return checkToBlack;
    }

    public void setCheckToBlack(boolean checkToBlack) {
        this.checkToBlack = checkToBlack;
    }

    public boolean isCheckToWhite() {
        return checkToWhite;
    }

    public void setCheckToWhite(boolean checkToWhite) {
        this.checkToWhite = checkToWhite;
    }

    public Side getCurrentMove() {
        return currentMove;
    }

    public void setCurrentMove(Side currentMove) {
        this.currentMove = currentMove;
    }
}
